package com.wzdigit.wms.wms.service.core.task;

import com.wzdigit.wms.basic.domain.task.TaskLog;
import com.wzdigit.wms.basic.mapper.core.task.TaskLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 后台任务执行日志 服务实现类
 * </p>
 *
 * @author 
 * @since 2021-03-19
 */
@Service
@Slf4j
public class TaskLogService  {

    @Autowired
    TaskLogMapper taskLogMapper;

    /**
     * 插入新纪录，返回新记录的主键
     * @param taskLog
     * @return
     */
    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
    public Integer addOne(TaskLog taskLog){

        int row = taskLogMapper.insert(taskLog);
        log.info("成功新增{}条记录",row);

        return taskLog.getTaskLogId();
    }

    public void updateOne(TaskLog taskLog) {

        int i = taskLogMapper.updateById(taskLog);
        log.info("成功更新{}条记录",i);
    }
}
